import axios from 'axios';

const actions = {
  getMenuList({ commit, state }) {
    let jwtAuth = JSON.parse(localStorage.getItem("jwtAuth"))
    return new Promise((resolve, reject) => {
      axios.post('/vrcrm/vrcrm/dicMenu/selectMenuListByUserId', {
        userId: jwtAuth.userId,
        siteId: jwtAuth.extMap.siteId,
        isFilterChildren: 2
      }).then(res => {
        if(res.data.status == 200) {

          res.data.data.forEach(item => {
            item.label = item.menuName;
            item.name = item.uri;
          })
          
          this.commit("updateInfo", ["menuList", res.data.data]);
          resolve(res.data.data)
        }


      }).catch(error => {
        reject(error)
      })
    })
  },
}


export default {
  actions
};